#ifndef _BSP_SERVO_H
#define _BSP_SERVO_H

#include <stdint.h>
#include "string.h"
#include "tim.h"

// 鑸垫満鏁版嵁
struct SERVO_Data {
	TIM_HandleTypeDef *servo_pwm_htimx_handle;
};
struct SERVO_Device {
    char *name;
    uint8_t NUM; // 鑸垫満鏍囧彿
	float setpwm;
    int (*Init)(struct SERVO_Device *pDev);
    int (*SetPwm)(struct SERVO_Device *pDev, int32_t set_pwm);
    void *priv_data;
};

/* 鑸垫満鏃嬭浆浣嶇疆(鑷�宸辫皟璇�) */
#define Turn_Num1						600
#define Turn_Num2						1500
#define Turn_Num3						2200

/*   搴曞眰澶栬�捐�剧疆瀹忓畾涔�    */
// PWM杈撳嚭瀵瑰簲瀹氭椂鍣�
#define Claw_Servo_TIM      &htim12 // 澶圭埅鑸垫満 
#define Move_Servo_TIM      &htim12 // 骞崇Щ鑸垫満 333HZ
#define Turn_Servo_TIM      &htim11 // 杞�鐩樿埖鏈� 50HZ
// PWM杈撳嚭閫氶亾
#define Claw_Servo_CHANNEL  TIM_CHANNEL_1 // 澶圭埅鑸垫満
#define Move_Servo_CHANNEL  TIM_CHANNEL_2 // 骞崇Щ鑸垫満 333HZ
#define Turn_Servo_CHANNEL  TIM_CHANNEL_1 // 杞�鐩樿埖鏈� 50HZ
// PWM鍗犵┖姣旇�剧疆
#define Claw_Servo_CCR      CCR1 // 澶圭埅鑸垫満
#define Move_Servo_CCR      CCR2 // 骞崇Щ鑸垫満 333HZ
#define Turn_Servo_CCR      CCR1 // 杞�鐩樿埖鏈� 50HZ
// PWM鏈€澶х殑鏈€灏忓€艰�惧畾
#define Claw_Servo_MIN      500
#define Claw_Servo_MAX      2500

#define Move_Servo_MIN      500
#define Move_Servo_MAX      2500

#define Turn_Servo_MIN      500
#define Turn_Servo_MAX      2500

struct SERVO_Device *GetServoDevice(char *name);

#endif
